package com.admin.common.util;

import org.apache.commons.lang3.StringUtils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 身份证工具类
 * zgq
 */
public class IDCardUtils extends StringUtils {

	public static boolean check(String cardNo) {
		if (cardNo.length() != 18) {
			return false;
		}
		Pattern pattern = Pattern.compile("^(\\d{6})(19|20)(\\d{2})(1[0-2]|0[1-9])(0[1-9]|[1-2][0-9]|3[0-1])(\\d{3})(\\d|X|x)?$");
		Matcher matcher = pattern.matcher(cardNo);

		if (!matcher.matches()) {
			return false;
		}
		return true;
	}
	public static void main(String[] args) {
		String cardNo = "41133019940610572X";// 36900119751204003X // 360481197512040035
		System.out.println(check(cardNo));
	}
}
